package lib

import (
	"fmt"
	"github.com/spf13/viper"
)

var Config *viper.Viper

func init() {
	// Default
	Config = viper.New()
	Config.SetConfigName("default")
	Config.AddConfigPath("config")
	Config.ReadInConfig()

	// Merge according to RUN_MODE
	Config.SetEnvPrefix("run")
	Config.AutomaticEnv()
	mode := Config.Get("mode")
	ginMode := Config.Get("ginMode")
	fmt.Sprintf("%v", ginMode)
	if mode != nil {
		Config.SetConfigName(fmt.Sprintf("%v", mode))
		Config.MergeInConfig()
	}
}
